package cn.tsyz.local.modules.user.service.impl;

import cn.tsyz.local.modules.user.model.User;
import cn.tsyz.local.modules.user.repository.UserRepository;
import cn.tsyz.local.modules.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Override
    public User findByUsername(String username) {
        return userRepository.findByUsername(username).orElse(null);
    }

    @Override
    public User findById(Long id) {
        return userRepository.findById(id).orElse(null);
    }

    @Override
    public boolean checkPassword(String rawPassword, String encodedPassword) {
        // 实际项目中应该使用BCrypt等加密算法
        return rawPassword.equals(encodedPassword);
    }
}
